package com.sdry.service.impl.cb;

import com.sdry.mapper.cb.AmoebaMapper;
import com.sdry.model.cb.AmoebaEntity;
import com.sdry.model.cb.DepreciationEntity;
import com.sdry.model.cb.HydroPower;
import com.sdry.model.cb.ShareEntity;
import com.sdry.service.cb.AmoebaService;
import com.sdry.service.cb.HydroPowerService;
import com.sdry.utils.BigDecimalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

@Service
public class AmoebaServiceImpl implements AmoebaService {

    @Autowired
    private HydroPowerService hydroPowerService;

    @Autowired
    private AmoebaMapper amoebaMapper;

    @Override
    public List<AmoebaEntity> listPartA(String date) {
        List<AmoebaEntity> list = new ArrayList<>();
        List<HydroPower> hydroPowers = hydroPowerService.getList();
        for (HydroPower hp : hydroPowers) {
            AmoebaEntity ae = new AmoebaEntity();
            ae.setLevel1("收入（未税）（A）");
            ae.setLevel2("外部收入");
            ae.setDetail("房租水电");
            ae.setPrice(hp.getPrice());
            ae.setLevel3(hp.getSupplier());
            //房租
            String multiply = BigDecimalUtil.multiply(hp.getWarehousequantity().toString(), hp.getPrice().toString());
            //水电费用
            String multiply1 = BigDecimalUtil.multiply(multiply, "0.16");
            ae.setMonery(new BigDecimal(BigDecimalUtil.add(multiply,multiply1)));
            list.add(ae);
        }
        AmoebaEntity ae = new AmoebaEntity();
        ae.setLevel2("内部部收入");
        ae.setLevel1("收入（未税）（A）");
        list.add(ae);
        return list;
    }
    public BigDecimal chaCheZheJiu(String date) {
        List<DepreciationEntity> list = amoebaMapper.chaCheZheJiu(date);
        BigDecimal bigDeMonery = DepreciationServiceImpl.getBigDeMonery(list);
        return bigDeMonery;
    }
    public BigDecimal cheCheZuLin(String date) {
        return amoebaMapper.cheCheZuLin(date);
    }
    @Override
    public BigDecimal zheJiuFie(String date) {
        List<DepreciationEntity> list = amoebaMapper.zheJiuFie(date);
        return DepreciationServiceImpl.getBigDeMonery(list);
    }
    @Override
    public BigDecimal qiTa(String date) {
        return amoebaMapper.qiTa(date);
    }

    @Override
    public BigDecimal gongZi(String date) {
        return amoebaMapper.gongZi(date);
    }

    @Override
    public BigDecimal guoQiaoFei(String date) {
        return amoebaMapper.guoQiaoFei(date);
    }

    @Override
    public BigDecimal youFei(String date) {
        return amoebaMapper.youFei(date);
    }

    @Override
    public BigDecimal weiXiuFei(String date) {
        return amoebaMapper.weiXiuFei(date);
    }

    @Override
    public BigDecimal waiGuChe(String date) {
        return amoebaMapper.waiGuChe(date);
    }

    @Override
    public BigDecimal fuWuFei(String date) {
        return amoebaMapper.fuWuFei(date);
    }

    @Override
    public BigDecimal sheBaoFei(String date) {
        return amoebaMapper.sheBaoFei(date);
    }

    @Override
    public BigDecimal daiTanFei(String date,Long warehouseId) {
        return amoebaMapper.daiTanFei(date,warehouseId);
    }

    @Override
    public List<ShareEntity> getShareList(String date, Long warehouseId) {
        return amoebaMapper.getShareList(date,warehouseId);
    }
}
